package com.ruoyi.information.controller.back;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.information.domain.back.CloudClassroomBack;
import com.ruoyi.information.service.back.ICloudClassroomBackService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 云课堂列表Controller
 * 后台
 * @author ruoyi
 * @date 2023-04-28
 */
@RestController
@RequestMapping("/classroomBack")
public class CloudClassroomBackController extends BaseController
{
    @Autowired
    private ICloudClassroomBackService cloudClassroomService;

    /**
     * 查询云课堂列表列表
     */
    @RequiresPermissions("information:classroom:list")
    @GetMapping("/list")
    public TableDataInfo list(CloudClassroomBack cloudClassroom)
    {
        startPage();
        List<CloudClassroomBack> list = cloudClassroomService.selectCloudClassroomList(cloudClassroom);
        return getDataTable(list);
    }

    /**
     * 导出云课堂列表列表
     */
    @RequiresPermissions("information:classroom:export")
    @Log(title = "云课堂列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CloudClassroomBack cloudClassroom)
    {
        List<CloudClassroomBack> list = cloudClassroomService.selectCloudClassroomList(cloudClassroom);
        ExcelUtil<CloudClassroomBack> util = new ExcelUtil<CloudClassroomBack>(CloudClassroomBack.class);
        util.exportExcel(response, list, "云课堂列表数据");
    }

    /**
     * 获取云课堂列表详细信息
     */
    @RequiresPermissions("information:classroom:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cloudClassroomService.selectCloudClassroomById(id));
    }

    /**
     * 新增云课堂列表
     */
    @RequiresPermissions("information:classroom:add")
    @Log(title = "云课堂列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CloudClassroomBack cloudClassroom)
    {
        return toAjax(cloudClassroomService.insertCloudClassroom(cloudClassroom));
    }

    /**
     * 修改云课堂列表
     */
    @RequiresPermissions("information:classroom:edit")
    @Log(title = "云课堂列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CloudClassroomBack cloudClassroom)
    {
        return toAjax(cloudClassroomService.updateCloudClassroom(cloudClassroom));
    }

    /**
     * 删除云课堂列表
     */
    @RequiresPermissions("information:classroom:remove")
    @Log(title = "云课堂列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cloudClassroomService.deleteCloudClassroomByIds(ids));
    }
}
